package testview.zhen.com.myapplication.hencoder

import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import testview.zhen.com.myapplication.R

class Main4Activity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main4)

    }

    companion object{
        fun toList() {
            //kotlin数组
            var a:IntArray = intArrayOf(1,2)
            println(a.component1())
            println(a.size)
            println(a.last())
            var i:IntIterator = a.iterator()
            while (i.hasNext()){
                println(i.next())
            }
            println()
        }

        fun printArray(){
            var time1 =  System.currentTimeMillis()
            var ints = Array<Int>(1000000) { i: Int -> i+1 }
            var time2 =  System.currentTimeMillis()
            println("打印的时间printArray${time2-time1}")//打印的时间printArray1373

        }

        fun printIntArray(){

            var time1 =  System.currentTimeMillis()
            var  ints = IntArray(1000000)
            for (i in 0..9999){
                ints[i] = i
            }
            var time2 =  System.currentTimeMillis()
            println("打印的时间printIntArray${time2-time1}")// 打印的时间printIntArray1
        }

        fun printList() {
            var time1 = System.currentTimeMillis()
            var ints = List<Int>(1000000) { i: Int ->
                i + 1
            }
            var time2 = System.currentTimeMillis()
            println("打印的时间printList${time2-time1}")//打印的时间printList1891
        }
    }


}
